package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.IncomeDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author nofish.yan@gmail.com
 * @date 2018/6/28.
 * 收益明细数据访问接口
 */
public interface IncomeDetailMapper extends MyMapper<IncomeDetail> {

    List<IncomeDetail> listCurrentIncomeDetail(@Param("employeeId") Integer employeeId, @Param("type") Integer type,
                                               @Param("start") Integer start, @Param("size") Integer size,
                                               @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<IncomeDetail> listHistoryIncomeDetail(@Param("employeeId") Integer employeeId, @Param("type") Integer type,
                                               @Param("start") Integer start, @Param("size") Integer size,
                                               @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    Integer countCurrentIncomeDetail(@Param("employeeId") Integer employeeId, @Param("type") Integer type,
                                     @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    Integer countHistoryIncomeDetail(@Param("employeeId") Integer employeeId, @Param("type") Integer type,
                                     @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    @Select("SELECT * FROM t_income_detail WHERE employee_id = #{employeeId} ORDER BY id DESC LIMIT 1")
    IncomeDetail findLastByEmployee(@Param("employeeId") Integer employeeId);

    Integer countByOrderIdAStatus(@Param("orderId") String orderId, @Param("status") Integer status);

}
